/**
* Copyright © 1998-2020, Glodon Inc. All Rights Reserved.
*/
package reactor2;

import static org.hamcrest.CoreMatchers.nullValue;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 
 * 此处填写类简介
 * <p>
 * 此处填写类说明
 * </p>
 * 
 * @author glodon
 * @since jdk1.6 2020年8月7日
 * 
 */

public class EventContext {
	private static int CORE_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 2;
	private static final int MAX_POOL_SIZE = CORE_POOL_SIZE * 4 < 256 ? 256 : CORE_POOL_SIZE * 4;
	ThreadPoolExecutor executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAX_POOL_SIZE, 5, TimeUnit.SECONDS,
			new LinkedBlockingDeque<Runnable>());
	Demultiplexer<Event> demultiplexer = new Demultiplexer<Event>();
	EventDispatcher eventDispatcher = new EventDispatcher();
	
	Selectlor selector = null;

	public EventContext() {
		selector = new Selectlor(demultiplexer,eventDispatcher,executor);
	}

	public ThreadPoolExecutor getExecutor() {
		return executor;
	}

	public void setExecutor(ThreadPoolExecutor executor) {
		this.executor = executor;
	}

	public Demultiplexer<Event> getDemultiplexer() {
		return demultiplexer;
	}

	public void setDemultiplexer(Demultiplexer<Event> demultiplexer) {
		this.demultiplexer = demultiplexer;
	}

	public EventDispatcher getEventDispatcher() {
		return eventDispatcher;
	}

	public void setEventDispatcher(EventDispatcher eventDispatcher) {
		this.eventDispatcher = eventDispatcher;
	}
}
